﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data;
using Model;

namespace BLL
{
    public class GenericSearchBLL : BaseBLL
    {
        public GenericSearchBLL(LoginInfo info)
        {
            loginInfo = info;
        }
        //public readonly static GenericSearchBLL Instance = new GenericSearchBLL();

        public DataTable GetViewData(string modelID, string sort, string order, string[] sql, IDataParameter[] para)
        {
            return new GenericSearchDAL(loginInfo).GetViewData(modelID, sort, order, sql, para);
        }

        public int GetViewDataCount(string schemaName, string viewName, DataTable whereCondition)
        {
            return new GenericSearchDAL(loginInfo).GetViewDataCount(schemaName, viewName, whereCondition);
        }

        public string GetTableData(string schemaName, string tableName, DataTable whereCondition, int pageSize, int pageIndex)
        {
            return new GenericSearchDAL(loginInfo).GetTableData(schemaName, tableName, whereCondition, pageSize, pageIndex);
        }
        public DataTable GetTableData(string modelID, string sort, string order, string[] sql, IDataParameter[] para)
        {
            return new GenericSearchDAL(loginInfo).GetTableData(modelID, sort, order, sql.ToArray(), para);
        }

        public int GetTableDataCount(string schemaName, string tableName, DataTable whereCondition)
        {
            return new GenericSearchDAL(loginInfo).GetTableDataCount(schemaName, tableName, whereCondition);
        }

        public string GetDQTables(string tableName)
        {
            return new GenericSearchDAL(loginInfo).GetDQTables(tableName);
        }

        public string DeleteDQ(string tableName, string date)
        {
            try
            {
                if (new GenericSearchDAL(loginInfo).DeleteDQ(tableName, date))
                    return "1";
                else
                    return "0";

            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
    }
}
